/**
 * 分数的加减乘除
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;

using llt = long long;
using pii = pair<int, int>;
using vi = vector<int>;

struct Rational{
    llt fenzi;
    llt fenmu;
    void input(){
        cin >> fenzi >> fenmu;
        refine();
    }    
    Rational(llt a=0, llt b=0):fenzi(a),fenmu(b){
        refine();
    }
    void refine() {
        if(0 == fenzi)return (void)(fenmu = 0);
        auto g = __gcd(fenzi, fenmu);
        fenzi /= g; fenmu /= g;
        if(fenmu < 0) fenzi = -fenzi, fenmu = -fenmu;
    }
    void ouput() const {cout << fenzi << " " << fenmu << endl;}
};

const Rational operator + (const Rational & a, const Rational & b){
    return {a.fenzi * b.fenmu + b.fenzi * a.fenmu, a.fenmu * b.fenmu};
}

const Rational operator - (const Rational & a, const Rational & b){
    return {a.fenzi * b.fenmu - b.fenzi * a.fenmu, a.fenmu * b.fenmu};
}

const Rational operator * (const Rational & a, const Rational & b){
    return {a.fenzi * b.fenzi, a.fenmu * b.fenmu};
}

const Rational operator / (const Rational & a, const Rational & b){
    return {a.fenzi * b.fenmu, a.fenmu * b.fenzi};
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0);
    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--){
        Rational a, b;
        a.input(); b.input();
        (a + b).ouput();
        (a - b).ouput();
        (a * b).ouput();
        (a / b).ouput();
    }
    return 0;
}